package com.building.controller;

import com.building.common.R;
import com.building.controller.BaseController.BaseController;
import com.building.entity.EngineeringStage;
import com.building.entity.EngineeringType;
import com.building.enums.REnum;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;

/**
 * @author yinjiahui
 * @create 2021-04-15 18:55
 */
@RestController
@RequestMapping("engineeringType")
public class EngineeringTypeController extends BaseController {

    /**
     *  查询所有的项目工程类型
     * @return
     */
    @GetMapping("selectEngineeringType")
    @ApiResponses({
            @ApiResponse(code=400,message="请求参数没填好"),
            @ApiResponse(code=404,message="请求路径没有或页面跳转路径不对")
    })
    public R selectEngineeringType(){
        return R.result(REnum.SUCCESS_QUERY,this.engineeringTypeService.selectEngineeringType());
    }


    /**
     *
     * 根据项目工程类型id删除
     *
     * @param engineeringTypeId
     * @return
     */
    @DeleteMapping("deleteEngineeringTypeByEngineeringTypeId/{engineeringTypeId}")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="根据项目工程类型id删除",name="engineeringTypeId",dataType="Integer",required=true,value="项目工程类型id",defaultValue="这个是默认值，可以不写"),
    })
    @ApiResponses({
            @ApiResponse(code=400,message="请求参数没填好"),
            @ApiResponse(code=404,message="请求路径没有或页面跳转路径不对")
    })
    public R deleteEngineeringTypeByEngineeringTypeId(@PathVariable("engineeringTypeId") Integer engineeringTypeId){
        this.engineeringTypeService.deleteEngineeringTypeByEngineeringTypeId(engineeringTypeId);
        return R.result(REnum.SUCCESS_DELETE);
    }

    /**
     *
     * 新增或修改项目工程阶段
     *
     * @param engineeringType
     * @return
     */
    @PostMapping("insertOrUpdateEngineeringType")
    @ApiResponses({
            @ApiResponse(code=400,message="请求参数没填好"),
            @ApiResponse(code=404,message="请求路径没有或页面跳转路径不对")
    })
    public R insertOrUpdateEngineeringType(@RequestBody EngineeringType engineeringType){
        return this.engineeringTypeService.insertOrUpdateEngineeringType(engineeringType);
    }


}
